package com.egao.orderB.controller;

import com.egao.common.core.web.BaseController;
import com.egao.common.core.web.JsonResult;
import com.egao.orderB.entity.EventsNum;
import com.egao.orderB.service.EventsNumService;
import com.egao.orderB.service.EventsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 *
 * 事件记录数量
 * @author : Doman
 * @date : 2021-05-25 15:42:33
 * @version ：1.0
 */

@Api(tags = "事件记录数量")
@RestController
@RequestMapping("/api/orderB/eventsNum")
public class EventsNumController extends BaseController {

	@Autowired
	private EventsNumService eventsNumService;
	@Autowired
	private EventsService eventsService;

//    /**
//     * 获取当前用户未看消息的数量
//     */
//    @ApiOperation(value ="获取当前用户未看消息的数量",notes = "" +
//            "module  传客户id\n" +
//            "",httpMethod = "POST")
//    @PostMapping("/getByUserId")
//    public JsonResult getByUserId(EventsNum eventsNum) {
//        int count = eventsService.getListNum();
//        eventsNum.setUserId(getLoginUserId());
//        int eventNum = eventsNumService.getByUserId(eventsNum);
//        if (eventNum == -1) {
//            return JsonResult.ok().setData(count);
//        } else {
//            return JsonResult.ok().setData(count - eventNum);
//        }
//        // 使用关联查询
//        //PageParam<eventsNum> pageParam = new PageParam<>();
//        //pageParam.put("id", id);
//        //List<eventsNum> records = eventsNumService.listAll(pageParam.getNoPageParam());
//        //return JsonResult.ok().setData(pageParam.getOne(records));
//    }

    /**
     * 修改事件记录数量
     */
    @ApiOperation(value ="修改事件记录数量",notes = "" +
            "module  传客户id\n" +
            "",httpMethod = "POST")
    @PostMapping("/update")
    public JsonResult update(Model model, EventsNum eventsNum) {
        eventsNum.setUserId(getLoginUserId());
        return eventsNumService.update(eventsNum, getLoginUser());
    }

//	/**
//	 * 分页查询列表
//	 */
//	@PreAuthorize("hasAuthority('orderB:eventsNum:list')")
//    //@OperLog(value = "事件记录数量", desc = "分页查询")
//    @ApiOperation(value ="分页查询事件记录数量",notes = "" +
//       "id:id\n" +
//       "userId:用户id\n" +
//       "module:模块\n" +
//       "nums:数量\n" +
//       "createTime:创建时间\n" +
//       "createUser:创建人\n" +
//       "updateTime:更新时间\n" +
//       "updateUser:更新人\n" +
//        "",httpMethod = "POST")
//    @ApiPageParam
//    @PostMapping("/page")
//    public JsonResult page(PageResult2<T> page, EventsNum eventsNum) throws Exception{
//        return eventsNumService.list(page, eventsNum, getLoginUser());
//    }
//
//    /**
//     * 查询全部事件记录数量
//     */
//    @PreAuthorize("hasAuthority('orderB:eventsNum:list')")
//    //@OperLog(value = "事件记录数量", desc = "查询全部")
//    @ApiOperation("查询全部事件记录数量")
//    @PostMapping("/list")
//    public JsonResult list(EventsNum eventsNum){
//        return eventsNumService.list(eventsNum, getLoginUser());
//    }
//
//    /**
//     * 根据id查询事件记录数量
//     */
//    @PreAuthorize("hasAuthority('orderB:eventsNum:list')")
//    //@OperLog(value = "事件记录数量", desc = "根据id查询")
//    @ApiOperation("根据id查询事件记录数量")
//    @PostMapping("/get")
//    public JsonResult get(EventsNum eventsNum) {
//        return eventsNumService.getById(eventsNum);
//		// 使用关联查询
//        //PageParam<eventsNum> pageParam = new PageParam<>();
//		//pageParam.put("id", id);
//        //List<eventsNum> records = eventsNumService.listAll(pageParam.getNoPageParam());
//        //return JsonResult.ok().setData(pageParam.getOne(records));
//    }
//
//
//    /**
//     * 添加事件记录数量
//     */
//    @PreAuthorize("hasAuthority('orderB:eventsNum:save')")
//    @OperLog(value = "事件记录数量", desc = "添加", param = false, result = true)
//    @ApiOperation(value ="添加事件记录数量",notes = "" +
//           "userId:用户id\n" +
//           "module:模块\n" +
//           "nums:数量\n" +
//        "",httpMethod = "POST")
//    @PostMapping("/save")
//    public JsonResult save(Model model, EventsNum eventsNum) {
//        return eventsNumService.save(eventsNum, getLoginUser());
//    }
//
//    /**
//     * 修改事件记录数量
//     */
//    @PreAuthorize("hasAuthority('orderB:eventsNum:update')")
//    @OperLog(value = "事件记录数量", desc = "修改", param = false, result = true)
//    @ApiOperation(value ="修改事件记录数量",notes = "" +
//           "id:id\n" +
//           "userId:用户id\n" +
//           "module:模块\n" +
//           "nums:数量\n" +
//        "",httpMethod = "POST")
//    @PostMapping("/update")
//    public JsonResult update(Model model, EventsNum eventsNum) {
//        return eventsNumService.update(eventsNum, getLoginUser());
//    }
//
//    /**
//     * 删除事件记录数量
//     */
//    @PreAuthorize("hasAuthority('orderB:eventsNum:remove')")
//    @OperLog(value = "事件记录数量", desc = "删除", result = true)
//    @ApiOperation("删除事件记录数量")
//    @PostMapping("/remove")
//    public JsonResult remove(EventsNum eventsNum ) {
//        return eventsNumService.remove(eventsNum, getLoginUser());
//    }

    /**
     * 批量添加事件记录数量
     */
    /**@RequiresPermissions("orderB:eventsNum:save")
    @OperLog(value = "事件记录数量", desc = "批量添加", param = false, result = true)
    @ResponseBody
    @PostMapping("/saveBatch")
    public JsonResult saveBatch(@RequestBody List<EventsNum> list) {
        if (eventsNumService.saveBatch(list)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }*/

    /**
     * 批量修改事件记录数量
     */
    /**@RequiresPermissions("orderB:eventsNum:update")
    @OperLog(value = "事件记录数量", desc = "批量修改", result = true)
    @ResponseBody
    @PostMapping("/updateBatch")
    public JsonResult updateBatch(@RequestBody BatchParam<EventsNum> batchParam) {
        if (batchParam.update(eventsNumService, "")) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }*/

    /**
     * 批量删除事件记录数量
     */
    /**@RequiresPermissions("orderB:eventsNum:remove")
    @OperLog(value = "事件记录数量", desc = "批量删除", result = true)
    @ResponseBody
    @PostMapping("/removeBatch")
    public JsonResult removeBatch(@RequestBody List<Integer> ids) {
        if (eventsNumService.removeByIds(ids)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }*/

}
